<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>一级路由 </title>
    <script src="vue.js"></script>
    <script src="vue-router.js"></script>
    <style>
        ul {
            list-style-type: none;
        }

        li {
            float: left;
            width: 150px;
        }

        li a {
            text-decoration: none;
        }

        .show {
            clear: both;
            margin-top: 50px;
        }
    </style>
</head>

<body>
    <template id="t1">
        <div>
            <h1>专题直播</h1>
        </div>
    </template>
    <template id="t2">
        <div>
            <h1>精品网课</h1>
        </div>
    </template>
    <template id="t3">
        <div>
            <h1>随堂课程</h1>
        </div>
    </template>
    <div id="app">
        <div>
            <ul>
                <li>
                    <router-link to="/zhuan">专题直播</router-link>
                </li>
                <li>
                    <router-link to="/jing">精品网课</router-link>
                </li>
                <li>
                    <router-link to="/sui">随堂课程</router-link>
                </li>
            </ul>
        </div>
        <div class="show">
            <!--承载展示数据 -->
            <router-view></router-view>
        </div>
    </div>
</body>

</html>
<script>
    var vm = new Vue({
        el: "#app",
        router: new VueRouter({
            routes: [
                {
                    path:"/zhuan",
                    component: {
                        template:"#t1"
                    }
                },
                {
                    path:"/jing",
                    component: {
                        template:"#t2"
                    }
                },
                {
                    path:"/sui",
                    component: {
                        template:"#t3"
                    }
                }
            ]

        }),
        // 默认路径
        beforeCreate: function () {
            this.$router.push("/zhuan");
        }

    });
</script>